﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlTypes;
using System.Data.SqlClient;/*引用Ado*/

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "server=.;database=Support；uid=sa;pwd=123456";
            SqlConnection sqlConnection = new SqlConnection(connectionString);/*函数调用*/
            sqlConnection.Open();/*打开到数据库的连接*/
            var sqlcommandString = "select * from Users";/*查询表*/
            SqlCommand sqlCommand = new SqlCommand(sqlcommandString,sqlConnection);/*初始化了一个命令对象，准备执行命令*/
            var sda = sqlCommand.ExecuteReader();
            while (sda.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}\t",sda["Id"],sda["name"],sda["stringId"]);/*打印表格*/
            }
            sqlConnection.Close();/*关闭到数据库的连接*/
        }
    }
}
